/*     */ package com.qmsk.business.member.memberCouponDetail.controller;
/*     */ 
/*     */ import com.qmsk.business.member.member.dao.MemberDAO;
/*     */ import com.qmsk.business.member.memberCouponDetail.dao.MemberCouponDetailDao;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.commons.lang.StringUtils;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"memberConpDt"})
/*     */ public class MemberCouponDetailController
/*     */ {
/*  34 */   private static final Logger logger = Logger.getLogger(MemberCouponDetailController.class);
/*     */ 
/*     */   @Autowired
/*     */   private MemberCouponDetailDao dao;
/*     */ 
/*     */   @Autowired
/*     */   private MemberDAO memberDao;
/*     */ 
/*     */   @RequestMapping(value={"find/memberId/state/{memberId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListMemberId(HttpServletRequest request, HttpServletResponse response, @PathVariable("memberId") Long memberId)
/*     */   {
/*     */     try
/*     */     {
/*  55 */       GsonEbRst gsonEbRst = this.dao.getGsonOfmemberId(memberId);
/*  56 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  58 */       logger.error(e);
/*  59 */       ResponseUtils.setErrorMsgResponse(
/*  60 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/memberConpDt/shopId/{shopId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void getIntOfMemberId(@PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize, HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  79 */     String openId = RequestUtils.getString(request, "openId");
/*     */     try {
/*  81 */       Long memberId = null;
/*  82 */       GsonEbRst gson = null;
/*  83 */       if ((shopId != null) && (StringUtils.isNotEmpty(openId))) {
/*  84 */         memberId = this.memberDao.getMemberIdOfOpenId(openId, shopId);
/*  85 */         if (memberId.longValue() > 0L) {
/*  86 */           gson = this.dao.getGsonOfAll(memberId, nPageIdx, nPageSize);
/*  87 */          }
/*  88 */         ResponseUtils.setErrorMsgResponse("您还不是会员", response);
/*  89 */         return;
/*     */       }
/*     */ 
/*  92 */       ResponseUtils.setErrorMsgResponse("获取openId失败", response);
/*  93 */       return;     } catch (SQLException e) {
/*  97 */       logger.error(e);
/*  98 */       ResponseUtils.setErrorMsgResponse(
/*  99 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"insert"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 115 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/* 117 */       int nResult = this.dao.insertJsonOneRow(sGsonInData);
/* 118 */       DbConnection.commit();
/* 119 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 120 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 121 */         response);
/*     */     } catch (Exception e) {
/* 123 */       DbConnection.rollback();
/* 124 */       logger.error(e);
/* 125 */       ResponseUtils.setErrorMsgResponse(
/* 126 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 127 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 143 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 145 */       String[] strParams = id.split(",");
/* 146 */       int nResult = this.dao.deleteParams(strParams);
/* 147 */       DbConnection.commit();
/* 148 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 149 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 150 */         response);
/*     */     } catch (Exception e) {
/* 152 */       DbConnection.rollback();
/* 153 */       logger.error(e);
/* 154 */       ResponseUtils.setErrorMsgResponse(
/* 155 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 156 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 172 */     String id = request.getParameter("id");
/* 173 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/* 175 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(sGsonInData);
/* 176 */       if (g == null) {
/* 177 */         ResponseUtils.setErrorMsgResponse(
/* 178 */           RequestUtils.getReadJsonDataErrorMessage(request), 
/* 179 */           response);
/*     */       } else {
/* 181 */         int nResult = this.dao.updateJsonOneRow(g, id);
/* 182 */         ResponseUtils.setSqlResultResponse(nResult, 
/* 183 */           RequestUtils.getSqlUpdateErrorMessage(sGsonInData, request), 
/* 184 */           response);
/*     */       }
/* 186 */       DbConnection.commit();
/*     */     } catch (Exception e) {
/* 188 */       DbConnection.rollback();
/* 189 */       logger.error(e);
/* 190 */       ResponseUtils.setErrorMsgResponse(
/* 191 */         RequestUtils.getSqlUpdateErrorMessage(sGsonInData, request) + ":" + 
/* 192 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.member.memberCouponDetail.controller.MemberCouponDetailController
 * JD-Core Version:    0.5.3
 */